/*
 * uart1.cpp
 *
 *  Created on: Aug 17, 2025
 *      Author: conearth
 */

#include <Uart1.h>
#include "uart_command.h"
#include <cstring>

Uart1::Uart1(UART_HandleTypeDef *_p_uart):UartTool(_p_uart)
{
	this->p_uart = _p_uart;

}

void Uart1::do_command(int buffer_pos, uint8_t cmd_id)
{
	// 做为头追master端，我只发送消息，不接受消息
	/*
	// 1. 处理各种命令
	switch (cmd_id)
	{

		case CMD_INITAL_ZERO:
			struct_CMD_INITAL_ZERO c1;
			memcpy(&c1, cmd_receive_buffer[buffer_pos].value.value,
					sizeof(struct_CMD_INITAL_ZERO));
			//p_array_motor[c1.which_motor]->setInitialMachineAngle(c1.initial_angle);
			//angle_target_base[c1.which_motor] = c1.initial_angle * _PI / 180.0f;
			break;
		default:
			//
			int j=1 ;

	}

	// 2.上报设备状态
	if (HAL_GetTick() - ms_previous > 1000)
	{
		//每1s上报一次状态数据。 目标机械角度，当前机械角度，误差
		uint8_t b2[26] =
		{	0};
		/*
		 generate_cmd_gimbal_status(b2, 0, p_m0,  &S0);
		 //UART_send_bytes(b2, 26);

		 generate_cmd_gimbal_status(b2, 1, p_m1,  &S1);
		 UART_send_bytes(b2, 26);

		ms_previous = HAL_GetTick();
	}
	*/

}



